<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>    
<%@ page import="cn.estore.util.*" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
request.setCharacterEncoding("UTF-8");
String username=request.getParameter("username");
String realname=request.getParameter("realname");
String age=request.getParameter("age");
int age1=Integer.parseInt(age);
String sex=request.getParameter("sex");
String pwd=request.getParameter("pwd");
String zhuanye=request.getParameter("zhuanye");
String email=request.getParameter("email");
String aihao[]=request.getParameterValues("aihao");
String aihao1="";
for(String ah:aihao)
{
	aihao1=aihao1+ah;
}
%>
<table border="1" align="center">
<tr><td colspan=2><center>您注册的信息是：</center></td></tr>
<tr><td>用户名：</td><td><%=username %></td></tr>
<tr><td>真实姓名：</td><td><%=realname %></td></tr>
<tr><td>年龄：</td><td><%=age%></td></tr>
<tr><td>性别：</td><td><%=sex%></td></tr>
<tr><td>密码：</td><td><%=pwd%></td></tr>
<tr><td>专业：</td><td><%=zhuanye%></td></tr>
<tr><td>邮箱：</td><td><%=email%></td></tr>
<tr><td>爱好：</td><td><%=aihao1%></td></tr>

%></td></tr>
</table>
<%
		Connection conn=null;
		DBConnection jdbc=new DBConnection();
		conn=jdbc.conn;
		String sql="INSERT INTO user(username,realname,age,sex,pwd,zhuanye,aihao,email) VALUES(?,?,?,?,?,?,?,?)";
		PreparedStatement stmt=conn.prepareStatement(sql);
		stmt.setString(1,username);
		stmt.setString(2,realname);
		stmt.setInt(3,age1);
		stmt.setString(4,sex);
		stmt.setString(5,pwd);
		stmt.setString(6,zhuanye);
		stmt.setString(7,aihao1);
		stmt.setString(8,email);
		int count=stmt.executeUpdate();
		if(count!=0)
		{
			out.print("注册成功！");
		}
		else{
			out.print("注册失败！");
		}
%>
</body>
</html>